#include <iostream>
#include <vector>
#include <string>
using namespace std;
char mx[100][100];
int judge_x(int r, int c)
{
    int num = 0, i = 0;
    while (true)
    {
        i++;
        if (i > r || i > c)
        {
            break;
        }
        if ((mx[r][c] == mx[r - i][c - i]) && (mx[r][c] == mx[r - i][c + i]) && (mx[r][c] == mx[r + i][c - i]) && (mx[r][c] == mx[r + i][c + i]))
        {
            num += 1;
        }
    }
    return num;
}
int main()
{
    int n, m;
    cin >> n >> m;
    int res = 0;
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < m; j++)
        {
            cin >> mx[i][j];
        }
    }
    for (size_t i = 1; i < n - 1; i++)
    {
        for (size_t j = 1; j < m - 1; j++)
        {
            res += judge_x(i, j);
        }
    }
    cout << res;
}